import tempfile
import os

sep = os.sep

temp_dir = tempfile.gettempdir() + sep + 'chatroom' + sep + 'files' + sep

try:
    os.makedirs(temp_dir)
except FileExistsError:
    pass


def save_file(data, filename, save_path=temp_dir):
    # 保存文件
    with open(save_path+filename, 'wb') as file:
        file.write(data)
